
	<div class="control-group row">
	
			<div class="navbar navbar-inverse navbar-fixed-top bs-docs-nav">
			  <ul class="breadcrumb">
				<li><a href="#">角色管理</a> <span class="divider">></span></li>
				<li class="active">添加角色</li>
			  </ul>
			</div>
			

<?php
	
	$attrbutes = array(
		'class' => 'form-horizontal',
		'id' => 'form_add'
	);
	echo form_open('role/add',$attrbutes);
?>
	 <div class="control-group">
		 <label for='name' class="control-label"><s>*</s>角色名</label>
		  <div class="controls">
			<input type="text"  name="name" data-rules="{required:true}"/>
		  </div>
	</div>
	
	<div class="control-group">
		<label for='name' class="control-label">角色描述</label>
		<div class="controls">
			<input type="text"  name="content"/>
		</div>
	</div>

	<div class="control-group">
		 <label for='name' class="control-label"><s>*</s>权限</label>
			<input type="hidden" name="action_list" data-rules="{required:true}">
		<div id="t1" class="span8"></div>
	</div>
	
   
   
   	<div class="actions-bar  centered">
			<input type="submit" class='button button-primary' checked="checked" value="添加角色"/>
			<input type="reset" class='button' checked="checked" value="重置"/>
	</div>
	
<?php

	echo form_close();
?>

	</div>
	
<!-- script start-->  
    <script type="text/javascript">
        BUI.use('bui/tree',function (Tree) {
        
      //树节点数据，
      //text : 文本，
      //id : 节点的id,
      //leaf ：标示是否叶子节点，可以不提供，根据childern,是否为空判断
      //expanded ： 是否默认展开
      //checked : 节点是否默认选中
      var data = 
                	<?php
                		if($actions){
                			echo json_encode($actions);
                		}
                	?>;

      //由于这个树，不显示根节点，所以可以不指定根节点
      var tree = new Tree.TreeList({
        render : '#t1',
        nodes : data,
        checkType: 'all', //checkType:勾选模式，提供了4中，all,onlyLeaf,none,custom
        showLine : true //显示连接线
      });
	  
      tree.render();
 
      tree.on('checkedchange',function(ev){
        var checkedNodes = tree.getCheckedNodes();
        var str = '';
        BUI.each(checkedNodes,function(node){
          str += node.id + ',';
        });
		$(':input[name="action_list"]').val(str);
      });
	  
    });
//form 验证
var Form = BUI.Form;
new Form.Form({
	srcNode:'#form_add'
}).render();
</script>